package com.beauty.dressing.module.mine.activity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.beauty.dressing.R;
import com.beauty.dressing.common.base.BaseActivity;
import com.beauty.dressing.common.bean.User;
import com.beauty.dressing.logic.control.LBController;
import com.beauty.dressing.module.person.activity.LoginActivity;
import com.beauty.dressing.module.person.presenter.LoginRegistControl;
import com.beauty.dressing.module.person.presenter.LoginRegistPresenter;

public class SettingsActivity extends BaseActivity {
    Button loginOut;

    @Override
    public void setContentView() {
        setContentView(R.layout.activity_setting);
    }

    @Override
    public void findView() {
        TextView title_txt = findViewById(R.id.title_txt);
        findViewById(R.id.left_img_btn).setOnClickListener(this);
        title_txt.setText("设置");
        loginOut = findViewById(R.id.loginOut);
        loginOut.setOnClickListener(this);
    }

    @Override
    public void initData() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.left_img_btn:
                this.finish();
                break;
            case R.id.loginOut:
                User user = LBController.getInstance().getCacheManager().getLoginUser();
                loginRegistPresenter.loginOut(user.member_id);
                break;
        }
    }

    LoginRegistPresenter loginRegistPresenter = new LoginRegistPresenter(new LoginRegistControl() {
        @Override
        public void onLoginOut(boolean isSuccess) {
            super.onLoginOut(isSuccess);
            if (isSuccess) {
                LBController.getInstance().logout();
                LBController.getInstance().getPageManager().clearPage();
                startActivity(new Intent(context, LoginActivity.class));
                showToast("退出成功");
            }


        }
    });
}
